import axios from 'axios'
axios.defaults.withCredentials=true;
export default {
    get (url,data=null,config=null) {
        if(data) config = Object.assign({params:data});
        return axios.get(url,config).then(val => {
            return new Promise((resolve,reject) => {
                resolve({status:val.status,msg:'成功',data:val.data})
            })
        })
    },
    post (url,data,config=null) {
        config = Object.assign({})
        return axios.post(url,data,config).then(val => {
            return new Promise((resolve,reject) => {
                resolve({status:val.status,msg:'成功',data:val.data})
            })
        })
    },
    put (url,data,config=null) {
        config = Object.assign({})
        return axios.put(url,data,config).then(val => {
            return new Promise((resolve,reject) => {
                resolve({status:val.status,msg:'成功',data:val.data})
            })
        })
    },
    delete (url,config=null) {
        config = Object.assign({})
        return axios.delete(url,config).then(val => {
            return new Promise((resolve,reject) => {
                resolve({status:val.status,msg:'成功',data:val.data})
            })
        })
    },
}
